
// 1.当前页面的样式
require('./personal.less');

// 2.公用js ---操作DOM,发送ajax,验证工具,本地存储
let dom = require('../../utils/dom.js');
require('../../lib/weui/weui.css')
let weui = require('../../lib/weui/weui.min.js')
require('../../assets/css/index.less');

require('../../assets/fontss/iconfont.css');
require('../../assets/fonts/iconfont.css');

let https = require('../../utils/https')

// 3.当前页面的js
dom.ready(function () {

    dom.addEvent('#headPic', function () {
        console.log(111);
        // console.log(dom.getEle('#btn'));
        dom.getEle('#btn1').click();
    })

    console.dir(dom.getEle('#btn1'));

    // btn1.addEventListener('click', function () {
    //     console.log(btn);
    // })
    dom.getEle('#btn1').addEventListener('change', function () {

        let upfd = this.files[0];


        let fd = new FormData();
        fd.append('file', upfd)

        https.post('/api/shared/uploadPortrait', fd, function (res) {
            console.log(res);
            if (res.errno == 0) {
                dom.getEle('#headPic').src = 'http://fitness.h5.itsource.cn:3701' + res.data.url;
            } else {
                alert('上传失败')
            }
        })
        // console.dir(file);
    })

})